import QtQuick 2.14

import QtQuick.Window 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts  1.12

Rectangle  {
    objectName: "main"
    id: root
    width: 1440
    height: 900
    visible: true

    function on_notify(str){
        status.text = str;
    }

    Flow{
        anchors.fill: parent
        width: parent.width
        height: parent.height

        Rectangle {
            width: 130;
            height: parent.height
            color: "black"
            Flow{
                id: element
                flow:Flow.TopToBottom //从上到下排列
                width: parent.width
                height: parent.height
                Button{
                    id: btn_serial
                    width: parent.width
                    height:80
                    onClicked: {
                        uart_choose.visible = true
                        net_choose.visible = false
                        proto_debug.visible = false
                    }
                    background: Image {
                        source: btn_serial.hovered? "qrc:///res/serial1.svg": "qrc:///res/serial.svg"
                    }
                }
                Text {
                    id: label_serial
                    text: qsTr("串口设置")
                    width: parent.width
                    color: "white"
                    font.pointSize: 15
                    anchors.top: btn_serial.bottom
                    leftPadding: 15

                }
                Button{
                    id: button_net
                    width: parent.width
                    height:80
                    anchors.top: label_serial.bottom
                    onClicked: {

                    }
                    background:  Image {
                        source: button_net.hovered? "qrc:///res/nethover.svg":"qrc:///res/net.svg"
                    }
                    onPressed:{
                        uart_choose.visible = false
                        net_choose.visible = true
                        proto_debug.visible = false
                    }
                }
                Text {
                    id: label_net
                    text: qsTr("网口设置")
                    width: parent.width
                    color: "white"
                    font.pointSize: 15
                    anchors.top: button_net.bottom
                    leftPadding: 15

                }
                Button{
                    id: button_proto
                    width: parent.width
                    height:80
                    anchors.top: label_net.bottom
                    onClicked: {
                        uart_choose.visible = false
                        net_choose.visible = false
                        proto_debug.visible = true
                        DataWrap.getValFromQml(1)
                    }
                    background: Image {
                        source: !button_proto.hovered? "qrc:///res/proto.svg":"qrc:///res/proto_hover.svg"
                    }
                }
                Text {
                    id: label_proto
                    text: qsTr("协议调试")
                    width: parent.width
                    color: "white"
                    font.pointSize: 15
                    anchors.top: button_proto.bottom
                    leftPadding: 15

                }
                Button{
                    id: button_tcp_swarm
                    width: parent.width
                    height:60
                    anchors.top: label_proto.bottom
                    onClicked: {
                        uart_choose.visible = false
                        net_choose.visible = false
                        proto_debug.visible = false
                        tcp_swarm.visible = true
                        DataWrap.getValFromQml(1)
                    }
                    background: Image {
                        source: "qrc:///res/proto.svg"
                    }

                }
                Text {
                    id: label_button_tcp_swarm
                    text: qsTr("tcp集群")
                    width: parent.width
                    color: "white"
                    font.pointSize: 15
                    anchors.top: button_tcp_swarm.bottom
                    leftPadding: 15
                }

                Text {
                    id: status
                    text: qsTr("未连接")
                    width: parent.width
                    color: "white"
                    font.pointSize: 10
                    anchors.bottom: parent.bottom
                    Layout.leftMargin: 10
                    Layout.bottomMargin: 10
                }

            }
        }
        SerialSelect{
            id: uart_choose
            width: parent.width - 130
            height: parent.height
        }

        NetSelect{
            id: net_choose
            width: parent.width - 130
            height: parent.height
        }

        ProtoDebug{
            id: proto_debug
            width: parent.width - 130
            height: parent.height
            visible: false
        }
        TcpSwarm{
            id: tcp_swarm
            width: parent.width - 130
            height: parent.height
            visible: false
        }

    }
}


